/*
 * @lc app=leetcode.cn id=2103 lang=typescript
 *
 * [2103] 环和杆
 */

// @lc code=start
function countPoints(rings: string): number {
    let cache = new Map<string, string[]>();
    for (let i = 0; i < rings.length; i += 2) {
        const c = rings[i];
        const pos = rings[i + 1];
        if (!cache.has(pos)) {
            cache.set(pos, []);
        }
        cache.get(pos)!.push(c);
    }
    let count = 0;
    for (const value of cache.values()) {
        value.includes("R") &&
            value.includes("G") &&
            value.includes("B") &&
            count++;
    }
    return count;
}
// @lc code=end
